<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Java,">





  <link rel="alternate" href="/atom.xml" title="DG" type="application/atom+xml">






<meta name="description" content="Day35JavaScript12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697">
<meta name="keywords" content="Java">
<meta property="og:type" content="article">
<meta property="og:title" content="Day35_JS">
<meta property="og:url" content="http://zhaowenhao99.github.io/2019/10/23/Day35_JS/index.html">
<meta property="og:site_name" content="DG">
<meta property="og:description" content="Day35JavaScript12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-10-25T13:14:51.137Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Day35_JS">
<meta name="twitter:description" content="Day35JavaScript12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://zhaowenhao99.github.io/2019/10/23/Day35_JS/">





  <title>Day35_JS | DG</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
    <a href="https://zhaowenhao99.github.io/" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">DG</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://zhaowenhao99.github.io/2019/10/23/Day35_JS/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="大狗">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/icon.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="DG">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Day35_JS</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-10-23T08:40:31+08:00">
                2019-10-23
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/学习/" itemprop="url" rel="index">
                    <span itemprop="name">学习</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
               <span title="字数统计">
                    1.5k 字 
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                    6 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="Day35"><a href="#Day35" class="headerlink" title="Day35"></a>Day35</h1><h3 id="JavaScript"><a href="#JavaScript" class="headerlink" title="JavaScript"></a>JavaScript</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br></pre></td><td class="code"><pre><span class="line">ECMAScript</span><br><span class="line">		<span class="number">1.</span>HTML引入js(掌握)</span><br><span class="line">			内部js:</span><br><span class="line">				&lt;script&gt;</span><br><span class="line">					编写js的代码</span><br><span class="line">				&lt;<span class="regexp">/script&gt;</span></span><br><span class="line"><span class="regexp">			外部js:</span></span><br><span class="line"><span class="regexp">				&lt;script src="js的路径"&gt;&lt;/</span>script&gt;</span><br><span class="line">		注意:</span><br><span class="line">			一旦采用第二种方式,也就是外部方式, 不要在script里面在写东西, 写了也没有效果</span><br><span class="line">		<span class="number">2.</span>注释和数据类型</span><br><span class="line">			<span class="comment">//单行</span></span><br><span class="line">			<span class="comment">/**/</span>多行</span><br><span class="line">			数据类型:</span><br><span class="line">				原始数据类型:(记忆性的知识点!!!!!)</span><br><span class="line">					number: 整数|小数|NAN</span><br><span class="line">					string: 所有的字符串</span><br><span class="line">					boolean: <span class="literal">true</span> | <span class="literal">false</span></span><br><span class="line">					<span class="literal">null</span>: 对象占位符</span><br><span class="line">					<span class="literal">undefined</span>:代表变量未赋值</span><br><span class="line">				引用数据类型:</span><br><span class="line">			变量的定义:(掌握!!!!!!!!!!!!!!!)</span><br><span class="line">				格式:</span><br><span class="line">					<span class="keyword">var</span> 变量名 = 值;</span><br><span class="line">				js是一种弱类型语言: 在定义变量的时候没有确定类型, 所有类型都可以接受,在赋值的时候确定类型</span><br><span class="line">				java是一种强类型语言: 在定义变量的时候确定了数据类型,只能该数据类型的数据</span><br><span class="line">		<span class="number">3.</span>运算符</span><br><span class="line">			一元运算符:</span><br><span class="line">				++,--: ----&gt; 技巧: 从左往右读表单式</span><br><span class="line">				+,-(号):---&gt;作用:可以将其他类型数据转成number类型	(了解!!!!!!!!!!!!!)</span><br><span class="line">					string ---&gt; number 规则: 如果是纯数字字符串,按照字面值, 否则转成<span class="literal">NaN</span></span><br><span class="line">					boolean ---&gt; number 规则: 如果是<span class="literal">true</span>的话转成<span class="number">1</span>,<span class="literal">false</span> 转为<span class="number">0</span></span><br><span class="line">					<span class="literal">null</span>---&gt; 规则转成<span class="number">0</span> 和<span class="literal">undefined</span>---&gt; 转成<span class="literal">NaN</span></span><br><span class="line">					对象转数字 ,没有规则</span><br><span class="line">					注意:<span class="number">1.</span>开发不建议使用+,-来转数字!!!!! <span class="number">2.</span><span class="literal">NaN</span>和任何数据进行运算结果还是<span class="literal">NaN</span>;</span><br><span class="line">			赋值运算</span><br><span class="line">				=,+=,-=,*=...</span><br><span class="line">			算数运算符:</span><br><span class="line">				+,-,*,/,%</span><br><span class="line">				/: 整数相除得到number类型,可以得到小数类型</span><br><span class="line">			比较运算符:</span><br><span class="line">				普通的:</span><br><span class="line">					&gt;,&lt;,&gt;=,&lt;=,==,!=</span><br><span class="line">					这些运算符如果类型不一样的话,先转换相同数据类型,接着在比较</span><br><span class="line">				特有的:</span><br><span class="line">					===,!==</span><br><span class="line">					===:全等: 数据类型和值都要一样才可以</span><br><span class="line">					!==:不全等:  数据类型和值有一个不一样就满足</span><br><span class="line">					例如:</span><br><span class="line">						<span class="keyword">var</span> a = <span class="string">"123"</span>;</span><br><span class="line">						<span class="keyword">var</span> b = <span class="number">123</span>;</span><br><span class="line">						a == b ----&gt;<span class="literal">true</span>:会转换类型</span><br><span class="line">						a === b ---&gt; <span class="literal">false</span>: 数据类型不一样</span><br><span class="line">						a !== b ---&gt; <span class="literal">true</span>: 数据类型不一样</span><br><span class="line">			逻辑运算符:</span><br><span class="line">				&amp;&amp;:</span><br><span class="line">				||:</span><br><span class="line">				!:</span><br><span class="line">				其他类型和boolean之间转换</span><br><span class="line">					string ----&gt; boolean : 规则 ----&gt; <span class="string">""</span>为<span class="literal">false</span>, 其他为<span class="literal">true</span></span><br><span class="line">					number ----&gt; boolean : 规则 ----&gt; <span class="number">0</span>和<span class="literal">NaN</span>为<span class="literal">false</span>,其他为<span class="literal">true</span></span><br><span class="line">					<span class="literal">null</span>和<span class="literal">undefined</span> ----&gt; 规则: ----&gt; 都是<span class="literal">false</span></span><br><span class="line">					对象 ---&gt; boolean ---&gt; 规则: ----&gt; 都为<span class="literal">true</span></span><br><span class="line">			特殊语法:(假装不知道!!!!!)</span><br><span class="line">				<span class="number">1.</span>分号可以省略</span><br><span class="line">				<span class="number">2.</span>定义变量如果省略 <span class="keyword">var</span>, 就是一个全局变量!!!!</span><br><span class="line">			流程控制语句</span><br><span class="line">				<span class="keyword">switch</span>(变量)&#123;</span><br><span class="line">					<span class="keyword">case</span> 值<span class="number">1</span>:</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">					.....</span><br><span class="line">					<span class="keyword">default</span>:</span><br><span class="line">						<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">if</span>(条件)&#123;</span><br><span class="line">				&#125;<span class="keyword">else</span> <span class="keyword">if</span>&#123;</span><br><span class="line">				&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">				&#125;</span><br><span class="line">				</span><br><span class="line">				<span class="keyword">while</span>(boolean类型)&#123;</span><br><span class="line">					</span><br><span class="line">				&#125;</span><br><span class="line">				</span><br><span class="line">				<span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; ; i++)&#123;</span><br><span class="line">				&#125;</span><br><span class="line">		内置对象:</span><br><span class="line">			<span class="built_in">Function</span>(掌握!!!!!!!!!)</span><br><span class="line">				<span class="number">1.</span>定义方式(掌握!!!!!!!!!!!!!!)</span><br><span class="line">					<span class="number">1.</span>第一种</span><br><span class="line">					<span class="function"><span class="keyword">function</span> 方法名(<span class="params">参数列表</span>)</span>&#123;</span><br><span class="line">						方法体;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="number">2.</span>第二种</span><br><span class="line">					<span class="keyword">var</span> 方法名 = <span class="function"><span class="keyword">function</span>(<span class="params">参数列表</span>)</span>&#123;</span><br><span class="line">						方法体;</span><br><span class="line">					&#125;</span><br><span class="line">				属性:</span><br><span class="line">					length:可以获取形参的个数</span><br><span class="line">					</span><br><span class="line">				特点:</span><br><span class="line">					<span class="number">1.</span>参数列表的数据类必须省略, 返回值类型也必须省略</span><br><span class="line">					<span class="number">2.</span>方法可以重名, 后面会将前面的方法覆盖掉</span><br><span class="line">					<span class="number">3.</span>方法的调用只和方法名有关系, 和参数列表没有关系, 其实参数列表只是方法编写者希望调用传入参数的个数</span><br><span class="line">						例如:	</span><br><span class="line">						<span class="function"><span class="keyword">function</span> <span class="title">add</span>(<span class="params">a,b</span>)</span>&#123;</span><br><span class="line">							<span class="keyword">return</span> a + b;</span><br><span class="line">						&#125;</span><br><span class="line">						<span class="keyword">var</span> sum = add(<span class="number">1</span>,<span class="number">2</span>);</span><br><span class="line">						<span class="keyword">var</span> sum = add(<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>);</span><br><span class="line">					<span class="number">4.</span>方法中有一个内置对象 <span class="built_in">arguments</span>, 可以接受任何参数, 类似java中的可变参数</span><br><span class="line">						<span class="function"><span class="keyword">function</span> <span class="title">add</span>(<span class="params"></span>)</span>&#123;</span><br><span class="line">							<span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; <span class="built_in">arguments</span>.length;i++)&#123;</span><br><span class="line">								</span><br><span class="line">							</span><br><span class="line">							&#125;</span><br><span class="line">						</span><br><span class="line">						&#125;</span><br><span class="line">					</span><br><span class="line">				调用方法:(掌握!!!!!!!!!!!!!!!)</span><br><span class="line">					方法名(实际参数)</span><br><span class="line">		</span><br><span class="line">			<span class="built_in">Array</span>(掌握!!!!!!!!!)</span><br><span class="line">				<span class="number">1.</span>创建数组</span><br><span class="line">					<span class="keyword">var</span> 数组名 = <span class="keyword">new</span> <span class="built_in">Array</span>(元素列表!!!!);</span><br><span class="line">					<span class="keyword">var</span> 数组名 = [元素的列表];</span><br><span class="line">				<span class="number">2.</span>操作数组</span><br><span class="line">					数组名[索引];</span><br><span class="line">					赋值:</span><br><span class="line">						数组名[<span class="number">5</span>] = <span class="number">10</span>;</span><br><span class="line">					获取值:</span><br><span class="line">						<span class="keyword">var</span> a = arr[<span class="number">5</span>];</span><br><span class="line">				<span class="number">3.</span>属性:</span><br><span class="line">					length: 获取数组的长度</span><br><span class="line">				<span class="number">4.</span>方法:</span><br><span class="line">					pop(); 删除最后一个元素并返回</span><br><span class="line">					push();添加元素到末尾,类似add方法</span><br><span class="line">					shift(); 删除第一个元素,并返回</span><br><span class="line">					unshift(); 向头添加一个元素, 返回新数组的长度</span><br><span class="line">				注意事项:</span><br><span class="line">					<span class="number">1.</span>数据类型是可变的</span><br><span class="line">					<span class="number">2.</span>长度可变</span><br><span class="line">				练习:</span><br><span class="line">					定义方法求数组的最大值</span><br><span class="line">					定义方法求数组的元素和</span><br><span class="line">			<span class="built_in">Date</span>(了解!!!!!!!!!!!!!!)</span><br><span class="line">				创建:</span><br><span class="line">					<span class="keyword">var</span> date = <span class="keyword">new</span> <span class="built_in">Date</span>();</span><br><span class="line">				方法:</span><br><span class="line">					getTime(); ----&gt;获取当前时间到<span class="number">1970</span>年<span class="number">1</span>月<span class="number">1</span>日<span class="number">8</span>点<span class="number">0</span>分<span class="number">0</span>秒的毫秒值</span><br><span class="line">					特点:不会重复, 将来以后用来解决缓存问题 </span><br><span class="line">			<span class="built_in">Math</span></span><br><span class="line">				ceil(); ---&gt;向上</span><br><span class="line">				floor() ---&gt;向下</span><br><span class="line">				round() ---&gt;四舍五入</span><br><span class="line">				random(); ----&gt; 生成[<span class="number">0</span>,<span class="number">1</span>)的随机数</span><br><span class="line">				如何生成[M,N]之间的随机数 [<span class="number">34</span>, <span class="number">46</span>] ---&gt; [<span class="number">0</span>,<span class="number">12</span>] + <span class="number">34</span> ---&gt;<span class="built_in">Math</span>.random();<span class="number">0</span>~<span class="number">0.9999999</span> * <span class="number">13</span> ---&gt; [<span class="number">0</span>,<span class="number">12.99999</span>] ---&gt; 向下取整 --&gt;[<span class="number">0</span>,<span class="number">12</span>]</span><br><span class="line">				</span><br><span class="line">				总结公式:</span><br><span class="line">					<span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random()*(	N - M + <span class="number">1</span>)) + M;</span><br><span class="line">					<span class="built_in">Math</span>.floor(<span class="built_in">Math</span>.random()*(	<span class="number">2</span>)) + <span class="number">1</span>;</span><br><span class="line">			正则表达式:</span><br><span class="line">				注意:他不是只针对js, 针对所有的语言</span><br><span class="line">				规则:</span><br><span class="line">					[]:匹配单个字符</span><br><span class="line">						例如:</span><br><span class="line">							[abc]: ---&gt;要求你的字符串只能有一个字符, 字符只能从abc中选其一</span><br><span class="line">							[a-z]: ---&gt;要求你的字符串只能有一个字符, 字符只能从a到z中选其一</span><br><span class="line">						\w:([a-zA-Z0<span class="number">-9</span>_]) 匹配单个字符, 字符的范围在 a-zA-Z0<span class="number">-9</span>_</span><br><span class="line">						\d:([<span class="number">0</span><span class="number">-9</span>])  匹配单个字符, 字符的范围在 <span class="number">0</span><span class="number">-9</span></span><br><span class="line">					量词:</span><br><span class="line">						?: 出现<span class="number">0</span>次或者<span class="number">1</span>次</span><br><span class="line">						+: 至少一次</span><br><span class="line">						*: <span class="number">0</span>次或者多次</span><br><span class="line">					范围量词:</span><br><span class="line">						&#123;m,n&#125; ---&gt;至少m次最多n次</span><br><span class="line">						&#123;m,&#125; ----&gt;至少m次,最多没有限制</span><br><span class="line">				</span><br><span class="line">					注意:</span><br><span class="line">						.: 在正则中代表匹配所有字符</span><br><span class="line">					扩展:</span><br><span class="line">						在<span class="built_in">String</span>中有几个方法和正则表达式有关的</span><br><span class="line">							split:</span><br><span class="line">							replaceAll:</span><br><span class="line">							如果遇到特殊字符,要记得转义</span><br><span class="line">				创建正则对象	</span><br><span class="line">					<span class="keyword">var</span> 变量名 = <span class="regexp">/正则表达式/</span>;</span><br><span class="line">					方法:</span><br><span class="line">						test(字符串); ----&gt; 判断字符串是否符合规则;</span><br><span class="line">						^: 正则的开始</span><br><span class="line">						$: 正则的结束</span><br><span class="line">				全局函数:</span><br><span class="line">					<span class="built_in">encodeURI</span>() ---&gt; 编码,将汉字变成%AE 十六进制样式, 其实为了向服务器传递数据, 因为http协议不支持中文</span><br><span class="line">					<span class="built_in">decodeURI</span>() ---&gt; 解码,将%AE 十六进制的样式, 在解码成中文</span><br><span class="line">					注意:开发过程浏览器会自动编码,服务器会自动解码</span><br><span class="line">					<span class="built_in">parseInt</span>(字符串的数字); </span><br><span class="line">					注意: 例如:  <span class="built_in">parseInt</span>(<span class="string">"123px"</span>); ---&gt; <span class="number">123</span>数字</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Java/" rel="tag"> <i class="fa fa-tag"></i> Java</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/10/22/Day34_CSS/" rel="next" title="Day34_CSS">
                <i class="fa fa-chevron-left"></i> Day34_CSS
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/10/25/Day37-JS高级/" rel="prev" title="Day37_JS高级">
                Day37_JS高级 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



<div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
<span class="jiathis_txt">分享到：</span>
<a class="jiathis_button_fav">收藏夹</a>
<a class="jiathis_button_copy">复制网址</a>
<a class="jiathis_button_email">邮件</a>
<a class="jiathis_button_weixin">微信</a>
<a class="jiathis_button_qzone">QQ空间</a>
<a class="jiathis_button_tqq">腾讯微博</a>
<a class="jiathis_button_douban">豆瓣</a>
<a class="jiathis_button_share">一键分享</a>

<a href="http://www.jiathis.com/share?uid=2140465" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank">更多</a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript">
var jiathis_config={
  data_track_clickback:true,
  summary:"",
  shortUrl:false,
  hideMore:false
}
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=" charset="utf-8"></script>
<!-- JiaThis Button END -->
      
</div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/icon.jpg" alt="大狗">
            
              <p class="site-author-name" itemprop="name">大狗</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">3</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">2</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/zhaowenhao99" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://zhaowenhao99.github.io" title="大狗之家" target="_blank">大狗之家</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Day35"><span class="nav-number">1.</span> <span class="nav-text">Day35</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#JavaScript"><span class="nav-number">1.0.1.</span> <span class="nav-text">JavaScript</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">大狗</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">39.5k</span>
  
</div>


  <div class="powered-by">个人专属</div>



  <span class="post-meta-divider">|</span>



<div class="powered-by">
<span id="sitetime"></span>
<script language="javascript">
  function siteTime(){
    window.setTimeout("siteTime()", 1000);
    var seconds = 1000;
    var minutes = seconds * 60;
    var hours = minutes * 60;
    var days = hours * 24;
    var years = days * 365;
    var today = new Date();
    var todayYear = today.getFullYear();
    var todayMonth = today.getMonth()+1;
    var todayDate = today.getDate();
    var todayHour = today.getHours();
    var todayMinute = today.getMinutes();
    var todaySecond = today.getSeconds();
    /* Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
    year - 作为date对象的年份，为4位年份值
    month - 0-11之间的整数，做为date对象的月份
    day - 1-31之间的整数，做为date对象的天数
    hours - 0(午夜24点)-23之间的整数，做为date对象的小时数
    minutes - 0-59之间的整数，做为date对象的分钟数
    seconds - 0-59之间的整数，做为date对象的秒数
    microseconds - 0-999之间的整数，做为date对象的毫秒数 */
    var t1 = Date.UTC(2019,04,5,15,00,00); //北京时间2018-2-13 00:00:00
    var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
    var diff = t2-t1;
    var diffYears = Math.floor(diff/years);
    var diffDays = Math.floor((diff/days)-diffYears*365);
    var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
    var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
    var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
    document.getElementById("sitetime").innerHTML=" 已运行"+/*diffYears+" 年 "+*/diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
  }/*因为建站时间还没有一年，就将之注释掉了。需要的可以取消*/
  siteTime();
</script>
</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":true},"log":false});</script></body>
<script type="text/javascript" src="/js/src/clicklove.js"></script>
</html>
